package com.hui.mapper;

import com.hui.entity.Product;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @Description
 * @date 2023/2/10 21:13
 */
public class ProductMapper implements  RowMapper<Product>{
    @Override
    public Product rowToEntity(ResultSet rs) {
        Product product=null;

        try {
            int productId = rs.getInt("productId");
            String productName = rs.getString("productName");
            int categoryId = rs.getInt("categoryId");
            int productNum = rs.getInt("productNum");
            String productDesc = rs.getString("productDesc");
            Date createTime = rs.getDate("createTime");
            String status = rs.getString("status");
            int warehouseId = rs.getInt("warehouseId");
            product=new Product(productId,productName,categoryId,productNum,productDesc,createTime,status,warehouseId);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return product;
    }
}
